package com.jd.ty.util;

import java.util.List;

import com.googlecode.jsonplugin.annotations.JSON;

public class Pager {
	// page total number
	private int total = 0;
	private int row = 20;

	// current page
	private int page = 0;
	private Boolean lastPage = false;

	// data
	private List dataRows;

	// total records
	private int records = 0;

	public Pager() {
	}

	public Pager(int row) {
		this.setRow(row);
	}


	public Pager(int rows, int page) {
		this.setRow(rows);
		this.setPage(page);
	}

	public int getRecords() {
		return records;
	}

	public void setRecords(int itemCount) {
		this.records = itemCount;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getTotal() {
		return (int) Math.ceil((double) records / row);
	}




	@JSON(serialize = false)
	public int getFromRowIndex() {
		return (page-1) * row;
	}



	public List getDataRows() {
		return dataRows;
	}

	public void setDataRows(List dataRows) {
		this.dataRows = dataRows;
	}

	public Boolean getLastPage() {
		return lastPage;
	}

	public void setLastPage(Boolean lastPage) {
		this.lastPage = lastPage;
	}



	public void setTotal(int total) {
		this.total = total;
	}

}
